package com.yaoxun.console.exception;

import com.yaoxun.console.code.ResponseCode;

/**
 * 校验异常，用于校验参数，逻辑校验，该异常不需要进行打印 <br />
 * 可以设置formats，用于String.formate 进行格式化
 * @author Loren
 * @Datetime 2021年5月13日 下午4:46:12
 */
public class ValidatorException extends RuntimeException {

    private static final long serialVersionUID = 1L;
    
    /**
     * 格式化
     */
    private Object[] formats;
    
    private ResponseCode responseCode;

    public ValidatorException(ResponseCode responseCode) {
        super(responseCode.msg());
        this.responseCode = responseCode;
    }
    
    /**
     * 构建异常
     * @param responseCode
     * @param formats 用于String.formate 
     */
    public ValidatorException(ResponseCode responseCode, Object... formats) {
        super(responseCode.msg());
        this.responseCode = responseCode;
        this.formats = formats;
    }
    
    /**
     * 构建异常
     * @param message
     * @param formats 用于String.formate 
     */
    public ValidatorException(String message, Object... formats) {
        super(message);
        this.formats = formats;
    }

    public Object[] getFormats() {
        return formats;
    }

    public void setFormats(Object[] formats) {
        this.formats = formats;
    }

    public ResponseCode getResponseCode() {
        return responseCode;
    }

    public void setResponseCode(ResponseCode responseCode) {
        this.responseCode = responseCode;
    }

}
